﻿<navigation:Page 
           xmlns:riaControls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.DomainServices"  
           x:Class="Komunikator.Views.EditAccount" 
           xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
           xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
           xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
           xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
           xmlns:local="clr-namespace:Komunikator.Controls"
           mc:Ignorable="d"
           xmlns:navigation="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Navigation"
           xmlns:domain="clr-namespace:Komunikator.Web"
           xmlns:Views="clr-namespace:Komunikator.Views"
           xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk"
           d:DesignWidth="640" d:DesignHeight="480"
           Title="EditAccount Page" 
           >
    <Grid x:Name="LayoutRoot" DataContext="{Binding}" VerticalAlignment="Top" HorizontalAlignment="Center">
        <Grid.RowDefinitions>
            <RowDefinition Height="auto" />
            <RowDefinition Height="auto" />
            <RowDefinition Height="auto" />
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="auto" />
            <ColumnDefinition Width="auto" />
        </Grid.ColumnDefinitions>

        <riaControls:DomainDataSource x:Name="UserPersonalDataSource" QueryName="GetUser_Personal_DataByUserName" AutoLoad="True">
            <riaControls:DomainDataSource.DomainContext>
                <domain:CommunicatorDomainContext />
            </riaControls:DomainDataSource.DomainContext>
            <riaControls:DomainDataSource.QueryParameters>
                <riaControls:Parameter ParameterName="userName" Value="{Binding Path=User.Name, Source={StaticResource WebContext}}" />
            </riaControls:DomainDataSource.QueryParameters>
        </riaControls:DomainDataSource>

        <riaControls:DomainDataSource x:Name="UserSettingsSource" QueryName="GetUser_SettingsByUserName" AutoLoad="True">
            <riaControls:DomainDataSource.DomainContext>
                <domain:CommunicatorDomainContext />
            </riaControls:DomainDataSource.DomainContext>
            <riaControls:DomainDataSource.QueryParameters>
                <riaControls:Parameter ParameterName="userName" Value="{Binding Path=User.Name, Source={StaticResource WebContext}}" />
            </riaControls:DomainDataSource.QueryParameters>
        </riaControls:DomainDataSource>
        
        <riaControls:DomainDataSource x:Name="CountriesSource" QueryName="GetCountries">
            <riaControls:DomainDataSource.DomainContext>
                <domain:CommunicatorDomainContext />
            </riaControls:DomainDataSource.DomainContext>
        </riaControls:DomainDataSource>

        <riaControls:DomainDataSource x:Name="CitiesSource" QueryName="GetCitiesInCountry">
            <riaControls:DomainDataSource.DomainContext>
                <domain:CommunicatorDomainContext />
            </riaControls:DomainDataSource.DomainContext>
            <riaControls:DomainDataSource.QueryParameters>
                <riaControls:Parameter ParameterName="country" Value="{Binding ElementName=autoCompleteBoxCountry, Path=Text}" />
            </riaControls:DomainDataSource.QueryParameters>
        </riaControls:DomainDataSource>

        
        <Grid x:Name="gridLayoutPersonalDataForm" Grid.Column="0" Grid.Row="0" Grid.RowSpan="2" Margin="10">
            <Grid.RowDefinitions>
                <RowDefinition Height="auto" />
                <RowDefinition Height="auto" />
                <RowDefinition Height="auto" />
                <RowDefinition Height="auto" />
                <RowDefinition Height="auto" />
                <RowDefinition Height="auto" />
                <RowDefinition Height="auto" />
                <RowDefinition Height="auto" />
                <RowDefinition Height="auto" />
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="auto" />
                <ColumnDefinition Width="auto" />                  
            </Grid.ColumnDefinitions>
            
            <TextBlock HorizontalAlignment="Center"  Text="Dane personalne" FontSize="14" Grid.ColumnSpan="2"/>
            <sdk:Label Content="Imię:" HorizontalAlignment="Right" Name="labelFirstName" Grid.Column="0" Grid.Row="1"/>
            <TextBox HorizontalAlignment="Left" Name="tbFirstName" Grid.Column="1" Grid.Row="1" Width="175" Margin="3" Text="{Binding Path=Data.FirstName, ElementName=UserPersonalDataSource, Mode=TwoWay}" />
            <sdk:Label Content="Nazwisko:" HorizontalAlignment="Right" Name="labelLastName" Grid.Column="0" Grid.Row="2"/>
            <TextBox HorizontalAlignment="Left" Name="tbLastName" Grid.Column="1" Grid.Row="2" Width="175" Margin="3" Text="{Binding Path=Data.LastName, ElementName=UserPersonalDataSource, Mode=TwoWay}" />
            <sdk:Label Content="Płeć:" HorizontalAlignment="Right" Name="labelSex" Grid.Column="0" Grid.Row="3" />
            <ComboBox HorizontalAlignment="Left" Name="comboBoxSex" Grid.Column="1" Grid.Row="3" Width="120" Margin="3" SelectedValuePath="Content" SelectedValue="{Binding Path=Data.Sex, ElementName=UserPersonalDataSource, Converter={StaticResource sexConverter}, Mode=TwoWay}">
                <ComboBoxItem Content="Mężczyzna" />
                <ComboBoxItem Content="Kobieta" />
            </ComboBox>

            <sdk:Label Content="Wiek:" HorizontalAlignment="Right" Name="labelAge" Grid.Column="0" Grid.Row="4"/>
            <TextBox HorizontalAlignment="Left" Name="tbAge" Grid.Column="1" Grid.Row="4" Width="175" Margin="3" Text="{Binding Path=Data.Age, ElementName=UserPersonalDataSource, Mode=TwoWay, ValidatesOnDataErrors=True, ValidatesOnExceptions=True, ValidatesOnNotifyDataErrors=True, NotifyOnValidationError=True, Converter={StaticResource NullableValueConverter}}" />

            <sdk:Label Content="Kraj:" HorizontalAlignment="Right" Name="labelCountry" Grid.Column="0" Grid.Row="5" />
            <sdk:AutoCompleteBox HorizontalAlignment="Left" Name="autoCompleteBoxCountry" Grid.Column="1" Grid.Row="5" Width="175" Margin="3" Text="{Binding Path=Data.Countries.CountryName, ElementName=UserPersonalDataSource, Mode=OneWay}" ItemsSource="{Binding Path=Data, ElementName=CountriesSource}" ValueMemberPath="CountryName">
                <sdk:AutoCompleteBox.ItemTemplate>
                    <DataTemplate>
                        <TextBlock Text="{Binding CountryName}" />
                    </DataTemplate>
                </sdk:AutoCompleteBox.ItemTemplate>
            </sdk:AutoCompleteBox>
            <sdk:Label Content="Miasto:" HorizontalAlignment="Right" Name="labelCity" Grid.Column="0" Grid.Row="6" />
            <sdk:AutoCompleteBox HorizontalAlignment="Left" Name="autoCompleteBoxCity" Grid.Column="1" Grid.Row="6"  Width="175" Margin="3" Text="{Binding Path=Data.Cities.CityName, ElementName=UserPersonalDataSource, Mode=OneWay}" ItemsSource="{Binding Path=Data, ElementName=CitiesSource}" ValueMemberPath="CityName">
                <sdk:AutoCompleteBox.ItemTemplate>
                    <DataTemplate>
                        <TextBlock Text="{Binding CityName}" />
                    </DataTemplate>
                </sdk:AutoCompleteBox.ItemTemplate>
            </sdk:AutoCompleteBox>
            <sdk:Label Content="Ulica:" HorizontalAlignment="Right" Name="labelStreet" Grid.Column="0" Grid.Row="7" />
            <TextBox HorizontalAlignment="Left" Name="textBoxStreet" Grid.Column="1" Grid.Row="7" Width="175" Margin="3" Text="{Binding Path=Data.Street, ElementName=UserPersonalDataSource, Mode=TwoWay}"/> 
            <Button Content="Zapisz" HorizontalAlignment="Right" Name="buttonSavePersonalData" Grid.ColumnSpan="2" Grid.Row="8" Width="75" Margin="3" Click="buttonSavePersonalData_Click" />
        </Grid>

        <Grid x:Name="gridLayoutChangeSettingsForm" Grid.Column="1" Grid.Row="0" Margin="10">
            <Grid.RowDefinitions>
                <RowDefinition Height="auto" />
                <RowDefinition Height="auto" />
                <RowDefinition Height="auto" />
                <RowDefinition Height="auto" />
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="auto" />
            </Grid.ColumnDefinitions>

            <TextBlock HorizontalAlignment="Center" Text="Ustawienia prywatności" FontSize="14" />
            <CheckBox Content="Wyświetl mnie w katalogu" HorizontalAlignment="Left" Grid.Row="1" Margin="3" Name="checkBoxDisplayMeInCatalog" IsChecked="{Binding Path=Data.VisibleInCatalog, ElementName=UserSettingsSource, Mode=TwoWay}"/>
            <CheckBox Content="Udostępniaj informację o dostępności kamery" HorizontalAlignment="Left" Grid.Row="2" Margin="3" Name="checkBoxShowCameraInfo"  IsChecked="{Binding Path=Data.ShowCamAvailable, ElementName=UserSettingsSource, Mode=TwoWay}"/>
            <Button Content="Zapisz" HorizontalAlignment="Right" Grid.Row="3" Margin="3" Name="buttonSavePrivacySettings" Width="75" Click="buttonSavePrivacySettings_Click" />
        </Grid>

        <Grid Grid.Column="1" Grid.Row="1" x:Name="LayoutChangePassword2" Margin="10">
            <Grid.RowDefinitions>
                <RowDefinition Height="auto" />
                <RowDefinition Height="auto" />
                <RowDefinition Height="auto" />
            </Grid.RowDefinitions>
            <TextBlock HorizontalAlignment="Center" Text="Ustawienia logowania" FontSize="14"/>
            <local:BusyIndicator x:Name="ChangePasswordBusyIndicator">    
            <local:CustomDataForm x:Name="ChangePasswordForm"
                                  CurrentItem="{Binding}"
                                  IsEnabled="True"
                                  AutoEdit="True" CommandButtonsVisibility="None" 
                                  Header="Zmień hasło"
                                  AutoGeneratingField="ChangePasswordForm_AutoGeneratingField"
                                  Style="{StaticResource DataFormStyle}"
                                  Grid.Row="1"/>
            </local:BusyIndicator>
            <Button Content="Zmień hasło" Grid.Row="2"  HorizontalAlignment="Right" VerticalAlignment="Bottom" Name="buttonChangePassword" Width="75" Click="buttonChangePassword_Click" />
        </Grid>
        <local:BusyIndicator HorizontalAlignment="Center" VerticalAlignment="Center" x:Name="busyIndicator" />
        <local:BusyIndicator HorizontalAlignment="Center" VerticalAlignment="Center" x:Name="busyIndicatorChangeSettings" />
    </Grid>
</navigation:Page>
